package com.fcmeditech.AsianSexyGirls;


import java.util.ArrayList;
import com.fcmeditech.AsianSexyGirls.CategaryObject;
import com.fcmeditech.AsianSexyGirls.R;
import com.fcmeditech.AsianSexyGirls.File.ListViewImageLoader;


import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListAdapter extends BaseAdapter {
    
    private Activity activity;
    private static LayoutInflater inflater=null;
    public ListViewImageLoader imageLoader; 
    private ArrayList<CategaryObject> listsexys;
    
    
    public ListAdapter(Activity a, ArrayList<CategaryObject> list) {
        activity = a;
        listsexys = list;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ListViewImageLoader(activity.getApplicationContext());
     //   imagerDownloader2=new ImageDownloader();
    }

    public int getCount() {
        return listsexys.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }
    
    public View getView(int position, View convertView, ViewGroup parent) {
      //  View vi=convertView;
        CategaryObject myGirl= listsexys.get(position);
        ListViewRowHolder holder;
        if(convertView==null){
        	convertView = inflater.inflate(R.layout.listgirl, null);
            holder=new ListViewRowHolder();
            holder.icon=(ImageView)convertView.findViewById(R.id.imgAvt);
            holder.name=(TextView) convertView.findViewById(R.id.tvTitle);
            holder.date=(TextView) convertView.findViewById(R.id.tvDateUpdate);
            convertView.setTag(holder);
        }else{
        	holder=(ListViewRowHolder)convertView.getTag();
        }
           
        holder.name.setText(myGirl.getCateName());
        holder.date.setText(myGirl.getDateUpdate());
        //--->Download and display Image to ListView        
        imageLoader.DisplayImage(myGirl.getUrl_image(),activity,holder.icon);
        
        return convertView;
    }
//----------Row Holder class-----------//
   static class ListViewRowHolder{
    	ImageView icon;
    	TextView name;
    	TextView date;
    }
//-------------------------------------//  
}